#include "stdafx.h"
#include <iostream>
#include "SyncDataCmd.h"

SyncDataCmd::SyncDataCmd()
{
}

SyncDataCmd::~SyncDataCmd()
{
}

bool SyncDataCmd::loadFile(const std::string & config_file)
{
    tinyxml2::XMLDocument doc;
    auto ret = doc.LoadFile(config_file.c_str());
    if (ret != tinyxml2::XML_SUCCESS)
    {
        std::cout << "load config file faild: " << config_file << ", error code is " << ret << std::endl;
        return false;
    }

    auto sync_data = doc.FirstChildElement("syncData");

    if (sync_data == nullptr)
    {
        return false;
    }

    auto vault_element = sync_data->FirstChildElement("vault");

    if (vault_element == nullptr)
    {
        return false;
    }

    vault.load(vault_element);

    return true;
}
